<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"/>
    <title>头像修改</title>
    <link rel="stylesheet" type="text/css" href="../../css/my.css">

</head>
<body ontouchstart="">
<div id="settingPage">
    <div id="settingTitle">
        <b>头像修改</b>
        <img src="../../images/return.png" onclick="MC.back()" id="settingRtn">
    </div>

    <div class="TXupfileDiv">
        <div class="posfileDiv">
            <a class="upfile">
                <input type="file" id="file">
            </a>
        </div>
        <div id="clipArea"></div>


        <div class="bottomDiv" style="display: none">
            <div class="btnList clearfix">
                <a class="button" id="clipBtn">保存</a>
                <!--<a class="button " id="saveBtn">保存</a> -->
            </div>
        </div>

        <div class="viewDiv">
            <div id="view"></div>

        </div>
    </div>
</div>
<script type="text/javascript" src="/h5/js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="/h5/css/all.css">
<script type="text/javascript" src="/h5/js/all.js"></script>

<script src="js/PhotoClip.js"></script>

<script>
    var base64 = '';
    var pc = new PhotoClip('#clipArea', {
        size: [260, 260],
        outputSize: 640,
        //adaptive: ['60%', '80%'],
        file: '#file',
        view: '#view',
        ok: '#clipBtn',
        //img: 'img/mm.jpg',
        loadStart: function () {
            console.log('开始读取照片');
        },
        loadComplete: function () {
            console.log('照片读取完成');
            $('.TXupfileDiv .posfileDiv').hide();
            $('.TXupfileDiv #clipArea,.TXupfileDiv .bottomDiv').show();
            $('#clipBtn').css('display','block');
        },
        done: function (dataURL) {
            // console.log(dataURL);
            base64 = dataURL;
            //  $('#saveBtn,.viewDiv').css('display', 'block');
            if (base64 == '') {
                MC.msg.alert('出现错误,请重试');
                return;
            }
            MC.apiD("setUserHead", {
                base64: base64
            }, function (json) {
                console.log(json);
                MC.back();
            });

        },
        fail: function (msg) {
            alert(msg);
        }
    });

</script>
</body>
</html>
